<?php

class UserRole extends Eloquent
{
	public static $timestamps = false;
	public static $table = 'users_roles';
	public static $key = 'roleid';
	
	public function user()
	{
		return $this->belongs_to('User');
	}

	public static function listRole(){

		Bundle::start('datagrid');

		$rolelist = UserRole::all();

		$datagrid = new Datagrid;
		$datagrid->setFields(array('roleid'=>'Role Id','role'=>'User Role Description'));
		$datagrid->setAction('edit','editRole',true,array('roleid','role'));
		$datagrid->setAction('delete','deleteRole',true,array('roleid'));
		$datagrid->setTable('users','creep');
		$datagrid->build($rolelist,'roleid');

		return $datagrid->render();

	}

	public function acl()
	{

		return $this->has_many('UserAcl', 'roleid');
	}

}
